#include "button.h"
#include "ioAT89S52.h"
#include "uart.h"
#include "util.h"

void InitKey()
{
  P1 = 0xFF;
}

uint8 GetKey()
{
  uint8_t keyValue = P1;
  if(keyValue == 0xff){
    return KEY_NO_PRESS;
  }
  for(uint8_t i = 0; i< 8;i++) {
    if( (keyValue&0x01) == 0){
      return i;
    }
    keyValue = keyValue >> 1;
  } 
  return KEY_NO_PRESS;
}

